package com.ktjy.ktmall.entity;

import com.mysql.cj.util.StringUtils;

import java.math.BigDecimal;
import java.util.List;

/**
 * 商品实体类，对应`t_goods_info`商品信息表
 * @version v1.0
 * @Author 郴州科泰
 * @Create 2024-07-19 - 15:42
 */
public class GoodsItem {
    private int id;
    private String goodsName;  // 商品名称
    private String spuCode; // 商品SPU，即商品的唯一标识
    private int categoryId; // 商品的二级分类id
    private int brandId;   // 品牌id
    private String goodsImg;  // 商品图片
    private String goodsDesc;  // 商品描述
    private BigDecimal goodsPrice;  // 商品价格
    private int publishStatus;  // 上架状态[0 - 下架，1 - 上架]
    private int orderNum;     // 排序值
    private String mainPictures;  // 商品主图的图片地址，多个图片地址使用逗号隔开
    private String [] mainImg;  // 商品主图的图片地址,按逗号拆分成数组.
    private String detailsPictures;  // 商品详情的图片地址，逗号隔开。
    private String [] picturesArr;  // 商品详情的图片地址数组。
    private List<SkuItem> skus;  // 商品的SKU列表
    private List<AttrItem> specs; // 商品的规格属性列表
    private CategoryItem categories;  // 商品分类对象
    private BrandItem brandItem;  // 品牌对象
    private String createTime;  // 创建时间
    private String updateTime;  // 更新时间

    public CategoryItem getCategories() {
        return categories;
    }

    public void setCategories(CategoryItem categories) {
        this.categories = categories;
    }

    public GoodsItem() {
    }

    public String getDetailsPictures() {
        return detailsPictures;
    }

    public void setDetailsPictures(String detailsPictures) {
        this.detailsPictures = detailsPictures;
    }

    public List<AttrItem> getSpecs() {
        return specs;
    }

    public String[] getMainImg() {
        return mainImg;
    }

    public void setMainImg(String[] mainImg) {
        this.mainImg = mainImg;
    }

    public BrandItem getBrandItem() {
        return brandItem;
    }

    public void setBrandItem(BrandItem brandItem) {
        this.brandItem = brandItem;
    }

    public void setSpecs(List<AttrItem> specs) {
        this.specs = specs;
    }

    public GoodsItem(int id, String goodsName, String spuCode, int categoryId, int brandId, String goodsImg, String goodsDesc, BigDecimal goodsPrice, int publishStatus, int orderNum, String mainPictures,String detailsPictures, String createTime, String updateTime) {
        this.id = id;
        this.goodsName = goodsName;
        this.spuCode = spuCode;
        this.categoryId = categoryId;
        this.brandId = brandId;
        this.goodsImg = goodsImg;
        this.goodsDesc = goodsDesc;
        this.goodsPrice = goodsPrice;
        this.publishStatus = publishStatus;
        this.orderNum = orderNum;
        this.mainPictures = mainPictures;
        // 如果mainPictures主图图片地址不为空，则以逗号进行分隔成数组赋值给mainImg
        if (!StringUtils.isNullOrEmpty(mainPictures)) {
            this.mainImg = mainPictures.split(",");
        }
        // 如果detailsPictures商品详情中图片地址不为空，则以逗号进行分隔成数组赋值给picturesArr
        if (!StringUtils.isNullOrEmpty(detailsPictures)) {
            this.picturesArr = detailsPictures.split(",");
        }
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public String[] getPicturesArr() {
        return picturesArr;
    }

    public void setPicturesArr(String[] picturesArr) {
        this.picturesArr = picturesArr;
    }

    public List<SkuItem> getSkus() {
        return skus;
    }

    public void setSkus(List<SkuItem> skus) {
        this.skus = skus;
    }
    public BigDecimal getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsPrice(BigDecimal goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getSpuCode() {
        return spuCode;
    }

    public void setSpuCode(String spuCode) {
        this.spuCode = spuCode;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public int getBrandId() {
        return brandId;
    }

    public void setBrandId(int brandId) {
        this.brandId = brandId;
    }

    public String getGoodsImg() {
        return goodsImg;
    }

    public void setGoodsImg(String goodsImg) {
        this.goodsImg = goodsImg;
    }

    public String getGoodsDesc() {
        return goodsDesc;
    }

    public void setGoodsDesc(String goodsDesc) {
        this.goodsDesc = goodsDesc;
    }

    public int getPublishStatus() {
        return publishStatus;
    }

    public void setPublishStatus(int publishStatus) {
        this.publishStatus = publishStatus;
    }

    public int getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(int orderNum) {
        this.orderNum = orderNum;
    }

    public String getMainPictures() {
        return mainPictures;
    }

    public void setMainPictures(String mainPictures) {
        this.mainPictures = mainPictures;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }
}
